# 1 实例化类 SweetPotato
# init 函数 cook_time  cook_state condiments
# cook 地瓜被烤函数
# add_condiments 添加调料
# str魔法方法

# 2 用类实例化对象
# 不断的烤地瓜/添加调料, 打印对象状态

# 1 定了类
class SweetPotato():
    # 1.1 初始化属性
    def __init__(self):
        self.cook_time = 0          # 被烤时间
        self.cook_state = '生的'     # 烤的状态
        self.condiments = []        # 调料列表
        pass

    # 1.2 地瓜被烤
    def cook(self, time):
        # 计算总时间
        self.cook_time += time

        # 根据总时间显示地瓜状态
        if 0<= self.cook_time < 3:
            self.cook_state = '生的'
        elif 3<= self.cook_time < 7:
            self.cook_state = '半生不熟'
        elif 7 <= self.cook_time < 12:
            self.cook_state = '熟的'
        elif self.cook_time >= 12:
            self.cook_state = '糊了'

    # 1.3 添加调料
    def add_condiments(self, condiments):
        self.condiments.append(condiments)

    # 1.4 魔法方法str
    def __str__(self):
        return f'这个地瓜被烤的时间:{self.cook_time}, 状态是:{self.cook_state}, 调料是:{self.condiments}'
        pass


if __name__ == '__main__':
    mypotato = SweetPotato()
    print(mypotato)

    print('-------------------------')
    mypotato.cook(2)
    mypotato.add_condiments("酱油")
    print(mypotato)

    print('-------------------------')
    mypotato.cook(2)
    mypotato.add_condiments("辣椒面")
    print(mypotato)

    print('-------------------------')
    mypotato.cook(2)
    print(mypotato)

    print('-------------------------')
    mypotato.cook(20)
    print(mypotato)


